package com.github.tyc.controller;

import cn.hutool.json.JSONUtil;
import com.github.tyc.entity.SysJobLog;
import com.github.tyc.service.JobLogService;
import com.github.tyc.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * 定时任务日志
 */
@RestController
@RequestMapping("/sys/scheduleLog")
public class JobLogController {
	@Autowired
	private JobLogService scheduleJobLogService;
	
	/**
	 * 定时任务日志列表
	 */
	@RequestMapping("/list")
	public String list(@RequestParam Map<String, Object> params){
		PageUtils page = scheduleJobLogService.queryPage(params);
		return JSONUtil.toJsonStr(page);
	}
	
	/**
	 * 定时任务日志信息
	 */
	@RequestMapping("/info/{logId}")
	public String info(@PathVariable("logId") Long logId){
		SysJobLog job = scheduleJobLogService.getById(logId);
		return JSONUtil.toJsonStr(job);
	}
}
